home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / Utility.mod < prev    next >
Text File  |  1994-08-08  |  22KB  |  731 lines

  1. (**************************************************************************
  2.  
  3.      $RCSfile: Utility.mod $
  4.   Description: Interface to utility.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 00:45:05 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE Utility;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT E := Exec, SYS := SYSTEM;
  31.  
  32.  
  33. (*-- Pointer declarations ---------------------------------------------*)
  34.  
  35. TYPE
  36.  
  37.   ClockDataPtr   * = CPOINTER TO ClockData;
  38.   HookPtr        * = CPOINTER TO Hook;
  39.   TagItemPtr     * = CPOINTER TO TagItem;
  40.   NamedObjectPtr * = CPOINTER TO NamedObject;
  41.  
  42.  
  43. (*-- Library definitions ----------------------------------------------*)
  44.  
  45. (*
  46. **      $VER: date.h 39.1 (20.1.92)
  47. **
  48. **      Date conversion routines ClockData definition.
  49. *)
  50.  
  51.  
  52. TYPE
  53.  
  54.   ClockData* = RECORD
  55.     sec  * : E.UWORD;
  56.     min  * : E.UWORD;
  57.     hour * : E.UWORD;
  58.     mday * : E.UWORD;
  59.     month* : E.UWORD;
  60.     year * : E.UWORD;
  61.     wday * : E.UWORD;
  62.   END; (* ClockData *)
  63.  
  64.  
  65. (*
  66. **      $VER: hooks.h 39.2 (16.6.93)
  67. **
  68. **      callback hooks
  69. *)
  70.  
  71.  
  72. TYPE
  73.  
  74. (* new standard hook structure *)
  75.   HookFunc * =
  76.     PROCEDURE (hook : HookPtr; object : E.APTR; message : E.APTR) : E.APTR;
  77.   AsmHookFunc * = PROCEDURE () : E.APTR;
  78.   (*
  79.     *** Oberon-A Note ***
  80.  
  81.     Oberon-A does not allow register parameters for normal procedures,
  82.     so if you use an AsmHookFunc, you must use SYS.GETREG to access
  83.     the parameters.  e.g:
  84.  
  85.     PROCEDURE MyHookFunc () : E.APTR
  86.       VAR hook : HookPtr; object : E.APTR; message : E.APTR;
  87.     BEGIN
  88.       SYS.GETREG (8, hook);
  89.       SYS.GETREG (10, object);
  90.       SYS.GETREG (9, message);
  91.       ...
  92.     END MyHookFunc;
  93.   *)
  94.  
  95.   Hook* = RECORD (E.MinNode)
  96.     entry   * : AsmHookFunc;   (* assembler entry point        *)
  97.     subEntry* : HookFunc;      (* often HLL entry point        *)
  98.     data    * : E.APTR;        (* owner specific               *)
  99.   END; (* Hook *)
  100.  
  101. (*
  102.  * Hook calling conventions:
  103.  *      A0 - pointer to hook data structure itself
  104.  *      A1 - pointer to parameter structure ("message") typically
  105.  *           beginning with a longword command code, which makes
  106.  *           sense in the context in which the hook is being used.
  107.  *      A2 - Hook specific address data ("object," e.g, GadgetInfo)
  108.  *
  109.  * Control will be passed to the routine hEntry.  For many
  110.  * High-Level Languages (HLL), this will be an assembly language
  111.  * stub which pushes registers on the stack, does other setup,
  112.  * and then calls the function at hSubEntry.
  113.  *
  114.  * The C standard receiving code is:
  115.  * CDispatcher( hook, object, message )
  116.  *     STRUCT Hook     *hook;
  117.  *     APTR             object;
  118.  *     APTR             message;
  119.  *
  120.  * NOTE that register natural order differs from this convention
  121.  * for C parameter order, which is A0,A2,A1.
  122.  *
  123.  * The assembly language stub for "vanilla" C parameter conventions
  124.  * could be:
  125.  
  126.  _hookEntry:
  127.         move.l  a1,-(sp)                ; push message packet pointer
  128.         move.l  a2,-(sp)                ; push object pointer
  129.         move.l  a0,-(sp)                ; push hook pointer
  130.         move.l  h_SubEntry(a0),a0       ; fetch C entry point ...
  131.         jsr     (a0)                    ; ... and call it
  132.         lea     12(sp),sp               ; fix stack
  133.         rts
  134.  
  135.  * with this function as your interface stub, you can write
  136.  * a Hook setup function as:
  137.  
  138.  SetupHook( hook, c_function, userdata )
  139.  STRUCT Hook    *hook;
  140.  ULONG          ( *c_function)();
  141.  VOID           *userdata;
  142.  {
  143.         ULONG   ( *hookEntry)();
  144.  
  145.         hook->h_Entry =         hookEntry;
  146.         hook->h_SubEntry =      c_function;
  147.         hook->h_Data =                  userdata;
  148.  }
  149.  
  150.  * with Lattice C pragmas, you can put the C function in the
  151.  * h_Entry field directly if you declare the function:
  152.  
  153. ULONG __saveds __asm
  154. CDispatcher(    register __a0 STRUCT Hook       *hook,
  155.                 register __a2 VOID              *object,
  156.                 register __a1 ULONG             *message );
  157.  *
  158.  ****)
  159.  
  160.  
  161. (*
  162. **      $VER: tagitem.h 40.1 (19.7.93)
  163. **
  164. **      extended specification mechanism
  165. *)
  166.  
  167. (*****************************************************************************)
  168.  
  169. (* Tags are a general mechanism of extensible data arrays for parameter
  170.  * specification and property inquiry. In practice, tags are used in arrays,
  171.  * or chain of arrays.
  172.  *
  173.  *)
  174.  
  175. TYPE
  176.  
  177.   Tag   * = SYS.LONGWORD;
  178.  
  179.   TagItem* = RECORD
  180.     tag*  : E.ULONG;
  181.     data* : Tag;
  182.   END; (* TagItem *)
  183.  
  184.   TagListPtr     * = CPOINTER TO ARRAY MAX (INTEGER) OF TagItem;
  185.  
  186. CONST
  187.  
  188. (* constants for Tag.tag, control tag values *)
  189.   tagDone  * = 0;    (* terminates array of TagItems. tiData unused *)
  190.   tagEnd   * = tagDone;
  191.   tagIgnore* = 1;    (* ignore this item, not end of array           *)
  192.   tagMore  * = 2;    (* tiData is pointer to another array of TagItems
  193.                       * note that this tag terminates the current array
  194.                       *)
  195.   tagSkip  * = 3;    (* skip this and the next tiData items         *)
  196.  
  197. (* differentiates user tags from control tags *)
  198.   tagUser  * = 80000000H;
  199.  
  200. (* If the tagUser bit is set in a tag number, it tells utility.library that
  201.  * the tag is not a control tag (like tagDone, tagIgnore, tagMore) and is
  202.  * instead an application tag. "USER" means a client of utility.library in
  203.  * general, including system code like Intuition or ASL, it has nothing to do
  204.  * with user code.
  205.  *)
  206.  
  207.  
  208. (*****************************************************************************)
  209.  
  210.  
  211. (* Tag filter logic specifiers for use with FilterTagItems() *)
  212.   tagFilterAND  * = 0;       (* exclude everything but filter hits   *)
  213.   tagFilterNOT  * = 1;       (* exclude only filter hits             *)
  214.  
  215.  
  216. (*****************************************************************************)
  217.  
  218.  
  219. (* Mapping types for use with MapTags() *)
  220.   mapRemoveNotFound * = 0;      (* remove tags that aren't in mapList *)
  221.   mapKeepNotFound * = 1;        (* keep tags that aren't in mapList   *)
  222.  
  223.  
  224. (*****************************************************************************)
  225.  
  226.  
  227. (*
  228. **      $VER: name.h 39.5 (11.8.93)
  229. **
  230. **      Namespace definitions
  231. **)
  232.  
  233. (*****************************************************************************)
  234.  
  235. TYPE
  236.  
  237. (* The named object structure *)
  238.   NamedObject * = RECORD
  239.     object * :  E.APTR; (* Your pointer, for whatever you want *)
  240.   END;
  241.  
  242. CONST
  243.  
  244. (* Tags for AllocNamedObject() *)
  245.   anoNameSpace * = 4000;        (* Tag to define namespace      *)
  246.   anoUserSpace * = 4001;        (* tag to define userspace      *)
  247.   anoPriority * = 4002;         (* tag to define priority       *)
  248.   anoFlags * = 4003;            (* tag to define flags          *)
  249.  
  250. (* Flags for tag anoFlags *)
  251.   nsNodups * = 0;         (* Default allow duplicates *)
  252.   nsCase * = 1;           (* Default to caseless... *)
  253.  
  254.  
  255. (*****************************************************************************)
  256.  
  257. (*
  258. **      $VER: pack.h 39.3 (10.2.93)
  259. **
  260. **      Control attributes for Pack/UnpackStructureTags()
  261. *)
  262.  
  263. (*****************************************************************************)
  264.  
  265. (* PackTable definition:
  266.  *
  267.  * The PackTable is a simple array of LONGWORDS that are evaluated by
  268.  * PackStructureTags() and UnpackStructureTags().
  269.  *
  270.  * The table contains compressed information such as the tag offset from
  271.  * the base tag. The tag offset has a limited range so the base tag is
  272.  * defined in the first longword.
  273.  *
  274.  * After the first longword, the fields look as follows:
  275.  *
  276.  *      +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
  277.  *      |
  278.  *      |  +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
  279.  *      | / \
  280.  *      | | |  +-- 00 = Byte, 01 = Word, 10 = Long, 11 = Bit
  281.  *      | | | / \
  282.  *      | | | | | /----- For bit operations: 1 = TAG_EXISTS is TRUE
  283.  *      | | | | | |
  284.  *      | | | | | | /-------------------- Tag offset from base tag value
  285.  *      | | | | | | |                 \
  286.  *      m n n o o p q q q q q q q q q q r r r s s s s s s s s s s s s s
  287.  *                                      \   | |               |
  288.  *      Bit offset (for bit operations) ----/ |               |
  289.  *                                            \                       |
  290.  *      Offset into data structure -----------------------------------/
  291.  *
  292.  * A -1 longword signifies that the next longword will be a new base tag
  293.  *
  294.  * A 0 longword signifies that it is the end of the pack table.
  295.  *
  296.  * What this implies is that there are only 13-bits of address offset
  297.  * and 10 bits for tag offsets from the base tag.  For most uses this
  298.  * should be enough, but when this is not, either multiple pack tables
  299.  * or a pack table with extra base tags would be able to do the trick.
  300.  * The goal here was to make the tables small and yet flexible enough to
  301.  * handle most cases.
  302.  *)
  303.  
  304. CONST
  305.  
  306.   pstSigned * = 31;
  307.   pstUnpack * = 30;      (* Note that these are active low... *)
  308.   pstPack   * = 29;      (* Note that these are active low... *)
  309.   pstExists * = 26;      (* Tag exists bit true flag hack...  *)
  310.  
  311.  
  312. (*****************************************************************************)
  313.  
  314. CONST
  315.  
  316.   pkCtrlPackUnpack * = 000000000H;
  317.   pkCtrlPackOnly   * = 040000000H;
  318.   pkCtrlUnpackOnly * = 020000000H;
  319.  
  320.   pkCtrlBYTE       * = 080000000H;
  321.   pkCtrlWORD       * = 088000000H;
  322.   pkCtrlLONG       * = 090000000H;
  323.  
  324.   pkCtrlUBYTE      * = 000000000H;
  325.   pkCtrlUWORD      * = 008000000H;
  326.   pkCtrlULONG      * = 010000000H;
  327.  
  328.   pkCtrlBit        * = 018000000H;
  329.   pkCtrlFlipBit    * = 098000000H;
  330.  
  331.  
  332. (*
  333.   The following C macros are included for information only.  They may be
  334.   implemented as procedures in the future if there is any demand for it.
  335.  
  336. (*****************************************************************************)
  337.  
  338.  
  339. (* Macros used by the next batch of macros below. Normally, you don't use
  340.  * this batch directly. Then again, some folks are wierd
  341.  *)
  342.  
  343. #define PK_BITNUM1(flg) ((flg) == 0x01 ? 0 : (flg) == 0x02 ? 1 : (flg) == 0x04 ? 2 : (flg) == 0x08 ? 3 : (flg) == 0x10 ? 4 : (flg) == 0x20 ? 5 : (flg) == 0x40 ? 6 : 7)
  344. #define PK_BITNUM2(flg) ((flg < 0x100 ? PK_BITNUM1(flg) : 8+PK_BITNUM1(flg >> 8)))
  345. #define PK_BITNUM(flg) ((flg < 0x10000 ? PK_BITNUM2(flg) : 16+PK_BITNUM2(flg >> 16)))
  346. #define PK_WORDOFFSET(flg) ((flg) < 0x100 ? 1 : 0)
  347. #define PK_LONGOFFSET(flg) ((flg) < 0x100  ? 3 : (flg) < 0x10000 ? 2 : (flg) < 0x1000000 ? 1 : 0)
  348. #define PK_CALCOFFSET(type,field) ((ULONG)(&((struct type * )0)->field))
  349.  
  350.  
  351. (*****************************************************************************)
  352.  
  353.  
  354. (* Some handy dandy macros to easily create pack tables
  355.  *
  356.  * Use PACK_STARTTABLE() at the start of a pack table. You pass it the
  357.  * base tag value that will be handled in the following chunk of the pack
  358.  * table.
  359.  *
  360.  * PACK_ENDTABLE() is used to mark the end of a pack table.
  361.  *
  362.  * PACK_NEWOFFSET() lets you change the base tag value used for subsequent
  363.  * entries in the table
  364.  *
  365.  * PACK_ENTRY() lets you define an entry in the pack table. You pass it the
  366.  * base tag value, the tag of interest, the type of the structure to use,
  367.  * the field name in the structure to affect and control bits (combinations of
  368.  * the various PKCTRL_XXX bits)
  369.  *
  370.  * PACK_BYTEBIT() lets you define a bit-control entry in the pack table. You
  371.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  372.  * affects. This macro should be used when the field being affected is byte
  373.  * sized.
  374.  *
  375.  * PACK_WORDBIT() lets you define a bit-control entry in the pack table. You
  376.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  377.  * affects. This macro should be used when the field being affected is word
  378.  * sized.
  379.  *
  380.  * PACK_LONGBIT() lets you define a bit-control entry in the pack table. You
  381.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  382.  * affects. This macro should be used when the field being affected is longword
  383.  * sized.
  384.  *
  385.  * EXAMPLE:
  386.  *
  387.  *    ULONG packTable[] =
  388.  *    {
  389.  *         PACK_STARTTABLE(GA_Dummy),
  390.  *         PACK_ENTRY(GA_Dummy,GA_Left,Gadget,LeftEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  391.  *         PACK_ENTRY(GA_Dummy,GA_Top,Gadget,TopEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  392.  *         PACK_ENTRY(GA_Dummy,GA_Width,Gadget,Width,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  393.  *         PACK_ENTRY(GA_Dummy,GA_Height,Gadget,Height,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  394.  *         PACK_WORDBIT(GA_Dummy,GA_RelVerify,Gadget,Activation,PKCTRL_BIT|PKCTRL_PACKUNPACK,GACT_RELVERIFY)
  395.  *         PACK_ENDTABLE
  396.  *    };
  397.  *)
  398.  
  399. #define PACK_STARTTABLE(tagbase)                           (tagbase)
  400. #define PACK_NEWOFFSET(tagbase)                    (-1L),(tagbase)
  401. #define PACK_ENDTABLE                                      0
  402. #define PACK_ENTRY(tagbase,tag,type,field,control)         (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field))
  403. #define PACK_BYTEBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | PK_CALCOFFSET(type,field) | (PK_BITNUM(flags) << 13L))
  404. #define PACK_WORDBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_WORDOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  405. #define PACK_LONGBIT(tagbase,tag,type,field,control,flags) (control | ((tag-tagbase) << 16L) | (PK_CALCOFFSET(type,field)+PK_LONGOFFSET(flags)) | ((PK_BITNUM(flags)&7) << 13L))
  406. *)
  407.  
  408. (*****************************************************************************)
  409.  
  410. (*
  411. **      $VER: utility.h 39.2 (18.9.92)
  412. *)
  413.  
  414. CONST
  415.  
  416.   name * = "utility.library";
  417.  
  418.  
  419. TYPE
  420.  
  421.   UtilityBasePtr* = CPOINTER TO UtilityBase;
  422.   UtilityBase * = RECORD (E.Library)
  423.     language * :  E.UBYTE;
  424.     reserved * :  E.UBYTE;
  425.   END;
  426.  
  427.  
  428. (*-- Library Base variable --------------------------------------------*)
  429.  
  430. VAR
  431.  
  432.   base* : UtilityBasePtr;
  433.  
  434.  
  435. (*-- Library Functions ------------------------------------------------*)
  436.  
  437. (*
  438. **      $VER: utility_protos.h 39.12 (10.2.93)
  439. *)
  440.  
  441. (*--- functions in V36 or higher (Release 2.0) ---*)
  442.  
  443. (* *** TagItem FUNCTIONS *** *)
  444.  
  445. LIBCALL (base : UtilityBasePtr) FindTagItemA*
  446.   ( tagVal  [0] : E.ULONG;
  447.     tagList [8] : ARRAY OF TagItem )
  448.   : TagItemPtr;
  449.   -30;
  450. LIBCALL (base : UtilityBasePtr) FindTagItem*
  451.   ( tagVal  [0] : E.ULONG;
  452.     tagList [8] : TagListPtr )
  453.   : TagItemPtr;
  454.   -30;
  455. LIBCALL (base : UtilityBasePtr) GetTagDataPA*
  456.   ( tagVal     [0] : E.ULONG;
  457.     defaultVal [1] : E.APTR;
  458.     tagList    [8] : ARRAY OF TagItem )
  459.   : E.APTR;
  460.   -36;
  461. LIBCALL (base : UtilityBasePtr) GetTagDataA*
  462.   ( tagVal     [0] : E.ULONG;
  463.     defaultVal [1] : E.ULONG;
  464.     tagList    [8] : ARRAY OF TagItem )
  465.   : E.ULONG;
  466.   -36;
  467. LIBCALL (base : UtilityBasePtr) GetTagDataP*
  468.   ( tagVal     [0] : E.ULONG;
  469.     defaultVal [1] : E.APTR;
  470.     tagList    [8] : TagListPtr )
  471.   : E.APTR;
  472.   -36;
  473. LIBCALL (base : UtilityBasePtr) GetTagData*
  474.   ( tagVal     [0] : E.ULONG;
  475.     defaultVal [1] : E.ULONG;
  476.     tagList    [8] : TagListPtr )
  477.   : E.ULONG;
  478.   -36;
  479. LIBCALL (base : UtilityBasePtr) PackBoolTagsA*
  480.   ( initialFlags [0] : SET;
  481.     tagList      [8] : ARRAY OF TagItem;
  482.     boolMap      [9] : ARRAY OF TagItem )
  483.   : SET;
  484.   -42;
  485. LIBCALL (base : UtilityBasePtr) PackBoolTags*
  486.   ( initialFlags [0] : SET;
  487.     tagList      [8] : TagListPtr;
  488.     boolMap      [9] : ARRAY OF TagItem )
  489.   : SET;
  490.   -42;
  491. LIBCALL (base : UtilityBasePtr) NextTagItem*
  492.   ( VAR tagListPtr [8] : TagItemPtr )
  493.   : TagItemPtr;
  494.   -48;
  495. LIBCALL (base : UtilityBasePtr) FilterTagChanges*
  496.   ( newTagList [8] : ARRAY OF TagItem;
  497.     oldTagList [9] : ARRAY OF TagItem;
  498.     apply      [0] : BOOLEAN );
  499.   -54;
  500. LIBCALL (base : UtilityBasePtr) MapTags*
  501.   ( tagList     [8] : ARRAY OF TagItem;
  502.     mapList     [9] : ARRAY OF TagItem;
  503.     includeMiss [0] : LONGINT );
  504.   -60;
  505. LIBCALL (base : UtilityBasePtr) AllocateTagItems*
  506.   ( numItems [0] : E.ULONG )
  507.   : TagListPtr;
  508.   -66;
  509. LIBCALL (base : UtilityBasePtr) CloneTagItemsA*
  510.   ( tagList [8] : ARRAY OF TagItem )
  511.   : TagListPtr;
  512.   -72;
  513. LIBCALL (base : UtilityBasePtr) CloneTagItems*
  514.   ( tagList [8] : TagListPtr )
  515.   : TagListPtr;
  516.   -72;
  517. LIBCALL (base : UtilityBasePtr) FreeTagItems*
  518.   ( tagList [8] : TagListPtr );
  519.   -78;
  520. LIBCALL (base : UtilityBasePtr) RefreshTagItemClones*
  521.   ( cloneList [8] : ARRAY OF TagItem;
  522.     origList  [9] : ARRAY OF TagItem );
  523.   -84;
  524. LIBCALL (base : UtilityBasePtr) TagInArrayA*
  525.   ( tagVal   [0] : E.ULONG;
  526.     tagArray [8] : ARRAY OF TagItem )
  527.   : BOOLEAN;
  528.   -90;
  529. LIBCALL (base : UtilityBasePtr) TagInArray*
  530.   ( tagVal   [0] : E.ULONG;
  531.     tagArray [8] : TagListPtr )
  532.   : BOOLEAN;
  533.   -90;
  534. LIBCALL (base : UtilityBasePtr) FilterTagItems*
  535.   ( tagList     [8] : ARRAY OF TagItem;
  536.     filterArray [9] : ARRAY OF TagItem;
  537.     logic       [0] : LONGINT )
  538.   : LONGINT;
  539.   -96;
  540.  
  541. (* *** HOOK FUNCTIONS *** * *)
  542.  
  543. LIBCALL (base : UtilityBasePtr) CallHookPkt*
  544.   ( hook        [8] : HookPtr;
  545.     object     [10] : E.APTR;
  546.     paramPacket [9] : E.APTR )
  547.   : E.ULONG;
  548.   -102;
  549.  
  550. (* *** DATE FUNCTIONS *** * *)
  551.  
  552. LIBCALL (base : UtilityBasePtr) Amiga2Date*
  553.   ( amigaTime [0] : E.ULONG;
  554.     VAR date  [8] : ClockData );
  555.   -120;
  556. LIBCALL (base : UtilityBasePtr) Date2Amiga*
  557.   ( VAR date [8] : ClockData )
  558.   : E.ULONG;
  559.   -126;
  560. LIBCALL (base : UtilityBasePtr) CheckDate*
  561.   ( VAR date [8] : ClockData )
  562.   : E.ULONG;
  563.   -132;
  564.  
  565. (* *** 32 BIT MATH FUNCTIONS *** * *)
  566.  
  567. LIBCALL (base : UtilityBasePtr) SMult32*
  568.   ( factor1 [0] : LONGINT;
  569.     factor2 [1] : LONGINT )
  570.   : LONGINT;
  571.   -138;
  572. LIBCALL (base : UtilityBasePtr) UMult32*
  573.   ( factor1 [0] : E.ULONG;
  574.     factor2 [1] : E.ULONG )
  575.   : E.ULONG;
  576.   -144;
  577.  
  578. (* NOTE: Quotient:Remainder returned in d0:d1 *)
  579.  
  580. LIBCALL (base : UtilityBasePtr) SDivMod32*
  581.   ( dividend [0] : LONGINT;
  582.     divisor  [1] : LONGINT )
  583.   : LONGINT;
  584.   -150;
  585. LIBCALL (base : UtilityBasePtr) UDivMod32*
  586.   ( dividend [0] : E.ULONG;
  587.     divisor  [1] : E.ULONG )
  588.   : E.ULONG;
  589.   -156;
  590.  
  591. (*--- functions in V37 or higher (Release 2.04) ---*)
  592.  
  593. (* *** International string routines *** *)
  594.  
  595. LIBCALL (base : UtilityBasePtr) Stricmp*
  596.   ( string1 [8] : ARRAY OF CHAR;
  597.     string2 [9] : ARRAY OF CHAR )
  598.   : LONGINT;
  599.   -162;
  600. LIBCALL (base : UtilityBasePtr) Strnicmp*
  601.   ( string1 [8] : ARRAY OF CHAR;
  602.     string2 [9] : ARRAY OF CHAR;
  603.     length  [0] : LONGINT )
  604.   : LONGINT;
  605.   -168;
  606. LIBCALL (base : UtilityBasePtr) ToUpper*
  607.   ( character [0] : CHAR )
  608.   : CHAR;
  609.   -174;
  610. LIBCALL (base : UtilityBasePtr) ToLower*
  611.   ( character [0] : CHAR )
  612.   : CHAR;
  613.   -180;
  614.  
  615. (*--- functions in V39 or higher (Release 3) ---*)
  616.  
  617. (* More tag Item functions *)
  618.  
  619. LIBCALL (base : UtilityBasePtr) ApplyTagChanges  *
  620.   ( list [8] : ARRAY OF TagItem; changeList [9] : ARRAY OF TagItem );
  621.   -186;
  622.  
  623. (* 64 bit integer muliply functions. The results are 64 bit quantities *)
  624. (* returned in D0 and D1 *)
  625.  
  626. LIBCALL (base : UtilityBasePtr) SMult64  *
  627.   ( arg1 [0] : LONGINT; arg2 [1] : LONGINT )
  628.   : LONGINT;
  629.   -198;
  630. LIBCALL (base : UtilityBasePtr) UMult64  *
  631.   ( arg1 [0] : E.ULONG; arg2 [1] : E.ULONG )
  632.   : E.ULONG;
  633.   -204;
  634.  
  635. (* Structure to Tag and Tag to Structure support routines *)
  636.  
  637. LIBCALL (base : UtilityBasePtr) PackStructureTagsA  *
  638.   ( pack [8] : E.APTR; packTable [9] : ARRAY  OF E.ULONG;
  639.     tagList [10] : ARRAY OF TagItem )
  640.   : E.ULONG;
  641.   -210;
  642. LIBCALL (base : UtilityBasePtr) PackStructureTags  *
  643.   ( pack [8] : E.APTR; packTable [9] : ARRAY  OF E.ULONG;
  644.     tagList [10] : TagListPtr )
  645.   : E.ULONG;
  646.   -210;
  647. LIBCALL (base : UtilityBasePtr) UnpackStructureTagsA  *
  648.   ( pack [8] : E.APTR; packTable [9] : ARRAY OF E.ULONG;
  649.     tagList [10] : ARRAY OF TagItem )
  650.   : E.ULONG;
  651.   -216;
  652. LIBCALL (base : UtilityBasePtr) UnpackStructureTags  *
  653.   ( pack [8] : E.APTR; packTable [9] : ARRAY OF E.ULONG;
  654.     tagList [10] : TagListPtr )
  655.   : E.ULONG;
  656.   -216;
  657.  
  658. (* New, object-oriented NameSpaces *)
  659.  
  660. LIBCALL (base : UtilityBasePtr) AddNamedObject  *
  661.   ( nameSpace [8] : NamedObjectPtr; object [9] : NamedObjectPtr )
  662.   : BOOLEAN;
  663.   -222;
  664. LIBCALL (base : UtilityBasePtr) AllocNamedObjectA  *
  665.   ( name [8] : ARRAY OF CHAR; tagList [9] : ARRAY OF TagItem )
  666.   : NamedObjectPtr;
  667.   -228;
  668. LIBCALL (base : UtilityBasePtr) AllocNamedObject  *
  669.   ( name [8] : ARRAY OF CHAR; tagList [9].. : Tag )
  670.   : NamedObjectPtr;
  671.   -228;
  672. LIBCALL (base : UtilityBasePtr) AttemptRemNamedObject  *
  673.   ( object [8] : NamedObjectPtr )
  674.   : BOOLEAN;
  675.   -234;
  676. LIBCALL (base : UtilityBasePtr) FindNamedObject  *
  677.   ( nameSpace [8] : NamedObjectPtr; name [9] : ARRAY OF CHAR;
  678.     lastObject [10] : NamedObjectPtr )
  679.   : NamedObjectPtr;
  680.   -240;
  681. LIBCALL (base : UtilityBasePtr) FreeNamedObject  *
  682.   ( object [8] : NamedObjectPtr );
  683.   -246;
  684. LIBCALL (base : UtilityBasePtr) NamedObjectName  *
  685.   ( object [8] : NamedObjectPtr )
  686.   : E.STRPTR;
  687.   -252;
  688. LIBCALL (base : UtilityBasePtr) ReleaseNamedObject  *
  689.   ( object [8] : NamedObjectPtr );
  690.   -258;
  691. LIBCALL (base : UtilityBasePtr) RemNamedObject  *
  692.   ( object [8] : NamedObjectPtr; message [9] : E.MessagePtr );
  693.   -264;
  694.  
  695. (* Unique ID generator *)
  696.  
  697. LIBCALL (base : UtilityBasePtr) GetUniqueID  * ()
  698.   : E.ULONG;
  699.   -270;
  700.  
  701.  
  702. (*-- Library Base variable --------------------------------------------*)
  703. (* $L- *)
  704.  
  705. (*-----------------------------------*)
  706. PROCEDURE* CloseLib ();
  707.  
  708. BEGIN (* CloseLib *)
  709.   IF base # NIL THEN E.base.CloseLibrary (base) END;
  710. END CloseLib;
  711.  
  712. (*-----------------------------------*)
  713. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  714.  
  715. BEGIN (* OpenLib *)
  716.   IF base = NIL THEN
  717.     base :=
  718.       SYS.VAL (
  719.         UtilityBasePtr,
  720.         E.base.OpenLibrary (name, E.libraryMinimum));
  721.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  722.     ELSIF mustOpen THEN HALT (100)
  723.     END;
  724.   END;
  725. END OpenLib;
  726.  
  727.  
  728. BEGIN
  729.   base := NIL
  730. END Utility.
  731.